package com.zxn.tablayoutsamples.ui;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.zxn.tablayout.ProminentTabLayout;
import com.zxn.tablayout.listener.CustomTabEntity;
import com.zxn.tablayout.listener.OnTabSelectListener;
import com.zxn.tablayoutsamples.R;
import com.zxn.tablayoutsamples.entity.TabEntity;

import java.util.ArrayList;
import java.util.List;

public class ProminentTabListActivity extends AppCompatActivity {

    public static void jumpTo(Context context) {
        Intent intent = new Intent(context, ProminentTabListActivity.class);
        context.startActivity(intent);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_prominent_tab_list);
        //setContentView(R.layout.activity_prominent_tab);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        List<CustomTabEntity> list = new ArrayList<>();
        list.add(new TabEntity("鱼宠"));
        list.add(new TabEntity("道具"));
        list.add(new TabEntity("背景"));
        list.add(new TabEntity("贝币"));
        ProminentTabLayout prominentTabC = findViewById(R.id.prominentTabC);
        prominentTabC.setTabData(list);
        //prominentTabC.setTabData(list, this, R.id.flContainer, list);

        List<CustomTabEntity> dayList = new ArrayList<>();
        dayList.add(new TabEntity("7天"));
        dayList.add(new TabEntity("30天"));
        dayList.add(new TabEntity("60天"));
        dayList.add(new TabEntity("90天"));
        ProminentTabLayout prominentTabD = findViewById(R.id.prominentTabD);
        prominentTabD.setTabData(dayList);
        prominentTabD.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
                Toast.makeText(ProminentTabListActivity.this, "onTabSelect:" + position, Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onTabReselect(int position) {

            }
        });
    }
}